package com.qf.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.entity.TbChoiceQuestion;
import com.qf.entity.TbJudgeQuestion;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface JudgeQuestionDao extends BaseMapper<TbJudgeQuestion> {

    /**
     * 根据试卷编号查询所有判断题
     * @param testpaperId
     * @return
     */
    @Select("SELECT * FROM `tb_judge_question` WHERE `question_id` IN (SELECT `question_id` FROM`tb_testpaper_question` WHERE `question_type` = 2 AND `testpaper_id` = #{testpaperId}) ")
    List<TbJudgeQuestion> findByIdAndType(Integer testpaperId);

    /**
     * 查询最后一条添加的判断题
     */
    @Select("SELECT `question_id` FROM `tb_judge_question` ORDER BY `question_id` DESC LIMIT 1")
    TbChoiceQuestion findJudgeById();
}
